
obj/bootblock.o:     file format elf32-i386


Disassembly of section .text:

00007c00 <start>:
.set CR0_PE_ON,				0x1						# protected mode enable flag

.globl start
start:
.code16												# Assemble for 16-bit mode
	cli												# Disable interrupts
    7c00:	fa                   	cli    
	cld												# String operations increment
    7c01:	fc                   	cld    

	# Set up the important data segment registers (DS, ES, SS).
	xorw %ax, %ax									# Segment number zero
    7c02:	31 c0                	xor    %eax,%eax
	movw %ax, %ds									# -> Data Segment
    7c04:	8e d8                	mov    %eax,%ds
	movw %ax, %es									# -> Extra Segment
    7c06:	8e c0                	mov    %eax,%es
	movw %ax, %ss									# -> Stack Segment
    7c08:	8e d0                	mov    %eax,%ss

00007c0a <seta20.1>:
	# Enable A20:
	#  For backwards compatibility with the earliest PCs, physical
	#  address line 20 is tied low, so that addresses higher than
	#  1MB wrap around to zero by default. This code undoes this.
seta20.1:
	inb $0x64, %al									# Wait for not busy
    7c0a:	e4 64                	in     $0x64,%al
	testb $0x2, %al
    7c0c:	a8 02                	test   $0x2,%al
	jnz seta20.1
    7c0e:	75 fa                	jne    7c0a <seta20.1>

	movb $0xd1, %al									# 0xd1 -> port 0x64
    7c10:	b0 d1                	mov    $0xd1,%al
	outb %al, $0x64
    7c12:	e6 64                	out    %al,$0x64

00007c14 <seta20.2>:

seta20.2:
	inb $0x64, %al									# Wait for not busy
    7c14:	e4 64                	in     $0x64,%al
	testb $0x2, %al
    7c16:	a8 02                	test   $0x2,%al
	jnz seta20.2
    7c18:	75 fa                	jne    7c14 <seta20.2>

	movb $0xdf, %al									# 0xdf -> port 0x60
    7c1a:	b0 df                	mov    $0xdf,%al
	outb %al, $0x60
    7c1c:	e6 60                	out    %al,$0x60

	# Switch from real to protected mode, using a bootstrap GDT
	# and segment translation that makes virtual addresses
	# identical to physical addresses, so that the
	# effective memory map does not change during the switch.
	lgdt gdtdesc
    7c1e:	0f 01 16             	lgdtl  (%esi)
    7c21:	6c                   	insb   (%dx),%es:(%edi)
    7c22:	7c 0f                	jl     7c33 <protcseg+0x1>
	movl %cr0, %eax
    7c24:	20 c0                	and    %al,%al
	orl $CR0_PE_ON, %eax
    7c26:	66 83 c8 01          	or     $0x1,%ax
	movl %eax, %cr0
    7c2a:	0f 22 c0             	mov    %eax,%cr0

	# Jump to next instruction, but in 32-bit code segment.
	# Switches processor into 32-bit mode.
	ljmp $PROT_MODE_CSEG, $protcseg
    7c2d:	ea 32 7c 08 00 66 b8 	ljmp   $0xb866,$0x87c32

00007c32 <protcseg>:

.code32												# Assemble for 32-bit mode
protcseg:
	# Set up the protected-mode data segment registers
	movw $PROT_MODE_DSEG, %ax						# Our data segment selector
    7c32:	66 b8 10 00          	mov    $0x10,%ax
	movw %ax, %ds									# -> DS: Data Segment
    7c36:	8e d8                	mov    %eax,%ds
	movw %ax, %es									# -> ES: Extra Segment
    7c38:	8e c0                	mov    %eax,%es
	movw %ax, %fs									# -> FS
    7c3a:	8e e0                	mov    %eax,%fs
	movw %ax, %gs									# -> GS
    7c3c:	8e e8                	mov    %eax,%gs
	movw %ax, %ss									# -> SS: Stack Segment
    7c3e:	8e d0                	mov    %eax,%ss

	# Set up the stack pointer and call into C.
	movl $0x0, %ebp
    7c40:	bd 00 00 00 00       	mov    $0x0,%ebp
	movl $start, %esp
    7c45:	bc 00 7c 00 00       	mov    $0x7c00,%esp
	call bootmain
    7c4a:	e8 d0 00 00 00       	call   7d1f <bootmain>

00007c4f <spin>:

	# If bootmain returns (it shouldn't), loop.
spin:
	jmp spin
    7c4f:	eb fe                	jmp    7c4f <spin>
    7c51:	8d 76 00             	lea    0x0(%esi),%esi

00007c54 <gdt>:
	...
    7c5c:	ff                   	(bad)  
    7c5d:	ff 00                	incl   (%eax)
    7c5f:	00 00                	add    %al,(%eax)
    7c61:	9a cf 00 ff ff 00 00 	lcall  $0x0,$0xffff00cf
    7c68:	00 92 cf 00 17 00    	add    %dl,0x1700cf(%edx)

00007c6c <gdtdesc>:
    7c6c:	17                   	pop    %ss
    7c6d:	00 54 7c 00          	add    %dl,0x0(%esp,%edi,2)
    7c71:	00 90 90 55 b9 84    	add    %dl,-0x7b46aa70(%eax)

00007c74 <cons_putc>:
	}
}

/* cons_puts - print a string to console */
static void
cons_putc(int c) {
    7c74:	55                   	push   %ebp
static inline void outw(uint16_t port, uint16_t data) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
    7c75:	b9 84 00 00 00       	mov    $0x84,%ecx
    7c7a:	89 e5                	mov    %esp,%ebp
    7c7c:	57                   	push   %edi
    7c7d:	bf 79 03 00 00       	mov    $0x379,%edi
    7c82:	56                   	push   %esi
    7c83:	31 f6                	xor    %esi,%esi
    7c85:	53                   	push   %ebx
    7c86:	89 c3                	mov    %eax,%ebx
    7c88:	eb 07                	jmp    7c91 <cons_putc+0x1d>
    7c8a:	89 ca                	mov    %ecx,%edx
    7c8c:	ec                   	in     (%dx),%al
    7c8d:	ec                   	in     (%dx),%al
    7c8e:	ec                   	in     (%dx),%al
    7c8f:	ec                   	in     (%dx),%al

/* lpt_putc - copy console output to parallel port */
static void
lpt_putc(int c) {
	int i;
	for (i = 0; !(inb(LPTPORT + 1) & 0x80) && i < 12800; i ++) {
    7c90:	46                   	inc    %esi
    7c91:	89 fa                	mov    %edi,%edx
    7c93:	ec                   	in     (%dx),%al
    7c94:	84 c0                	test   %al,%al
    7c96:	78 08                	js     7ca0 <cons_putc+0x2c>
    7c98:	81 fe 00 32 00 00    	cmp    $0x3200,%esi
    7c9e:	75 ea                	jne    7c8a <cons_putc+0x16>
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
    7ca0:	ba 78 03 00 00       	mov    $0x378,%edx
    7ca5:	88 d8                	mov    %bl,%al
    7ca7:	ee                   	out    %al,(%dx)
    7ca8:	b0 0d                	mov    $0xd,%al
    7caa:	b2 7a                	mov    $0x7a,%dl
    7cac:	ee                   	out    %al,(%dx)
    7cad:	b0 08                	mov    $0x8,%al
    7caf:	ee                   	out    %al,(%dx)
    7cb0:	be d4 03 00 00       	mov    $0x3d4,%esi
    7cb5:	b0 0e                	mov    $0xe,%al
    7cb7:	89 f2                	mov    %esi,%edx
    7cb9:	ee                   	out    %al,(%dx)
static inline void outw(uint16_t port, uint16_t data) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
    7cba:	bf d5 03 00 00       	mov    $0x3d5,%edi
    7cbf:	89 fa                	mov    %edi,%edx
    7cc1:	ec                   	in     (%dx),%al
cga_putc(int c) {
	int pos;

	// cursor position: col + 80*row.
	outb(CRTPORT, 14);
	pos = inb(CRTPORT + 1) << 8;
    7cc2:	0f b6 c8             	movzbl %al,%ecx
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
    7cc5:	89 f2                	mov    %esi,%edx
    7cc7:	c1 e1 08             	shl    $0x8,%ecx
    7cca:	b0 0f                	mov    $0xf,%al
    7ccc:	ee                   	out    %al,(%dx)
static inline void outw(uint16_t port, uint16_t data) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
    7ccd:	89 fa                	mov    %edi,%edx
    7ccf:	ec                   	in     (%dx),%al
	outb(CRTPORT, 15);
	pos |= inb(CRTPORT + 1);
    7cd0:	0f b6 f8             	movzbl %al,%edi
    7cd3:	09 f9                	or     %edi,%ecx

	if (c == '\n') {
    7cd5:	83 fb 0a             	cmp    $0xa,%ebx
    7cd8:	75 0e                	jne    7ce8 <cons_putc+0x74>
		pos += 80 - pos % 80;
    7cda:	89 c8                	mov    %ecx,%eax
    7cdc:	b3 50                	mov    $0x50,%bl
    7cde:	99                   	cltd   
    7cdf:	83 c1 50             	add    $0x50,%ecx
    7ce2:	f7 fb                	idiv   %ebx
    7ce4:	29 d1                	sub    %edx,%ecx
    7ce6:	eb 11                	jmp    7cf9 <cons_putc+0x85>
	}
	else {
		crt[pos ++] = (c & 0xff) | 0x0700;
    7ce8:	66 81 e3 ff 00       	and    $0xff,%bx
    7ced:	80 cf 07             	or     $0x7,%bh
    7cf0:	66 89 9c 09 00 80 0b 	mov    %bx,0xb8000(%ecx,%ecx,1)
    7cf7:	00 
    7cf8:	41                   	inc    %ecx
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
    7cf9:	bb d4 03 00 00       	mov    $0x3d4,%ebx
    7cfe:	b0 0e                	mov    $0xe,%al
    7d00:	89 da                	mov    %ebx,%edx
    7d02:	ee                   	out    %al,(%dx)
    7d03:	be d5 03 00 00       	mov    $0x3d5,%esi
    7d08:	89 c8                	mov    %ecx,%eax
    7d0a:	c1 f8 08             	sar    $0x8,%eax
    7d0d:	89 f2                	mov    %esi,%edx
    7d0f:	ee                   	out    %al,(%dx)
    7d10:	b0 0f                	mov    $0xf,%al
    7d12:	89 da                	mov    %ebx,%edx
    7d14:	ee                   	out    %al,(%dx)
    7d15:	88 c8                	mov    %cl,%al
    7d17:	89 f2                	mov    %esi,%edx
    7d19:	ee                   	out    %al,(%dx)
/* cons_puts - print a string to console */
static void
cons_putc(int c) {
	lpt_putc(c);
	cga_putc(c);
}
    7d1a:	5b                   	pop    %ebx
    7d1b:	5e                   	pop    %esi
    7d1c:	5f                   	pop    %edi
    7d1d:	5d                   	pop    %ebp
    7d1e:	c3                   	ret    

00007d1f <bootmain>:

/* bootmain - the entry of bootloader */
void
bootmain(void) {
    7d1f:	55                   	push   %ebp
    7d20:	89 e5                	mov    %esp,%ebp
    7d22:	57                   	push   %edi
    7d23:	56                   	push   %esi
static inline void outw(uint16_t port, uint16_t data) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
    7d24:	be f7 01 00 00       	mov    $0x1f7,%esi
    7d29:	53                   	push   %ebx
    7d2a:	bb 01 00 00 00       	mov    $0x1,%ebx
    7d2f:	83 ec 04             	sub    $0x4,%esp
    7d32:	c7 45 f0 00 00 01 00 	movl   $0x10000,-0x10(%ebp)
    7d39:	89 f2                	mov    %esi,%edx
    7d3b:	ec                   	in     (%dx),%al
}

/* waitdisk - wait for disk ready */
static void
waitdisk(void) {
	while ((inb(0x1F7) & 0xC0) != 0x40)
    7d3c:	25 c0 00 00 00       	and    $0xc0,%eax
    7d41:	83 f8 40             	cmp    $0x40,%eax
    7d44:	75 f3                	jne    7d39 <bootmain+0x1a>
			: "memory", "cc");
}

static inline void
outb(uint16_t port, uint8_t data) {
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
    7d46:	ba f2 01 00 00       	mov    $0x1f2,%edx
    7d4b:	b0 01                	mov    $0x1,%al
    7d4d:	ee                   	out    %al,(%dx)
    7d4e:	b2 f3                	mov    $0xf3,%dl
    7d50:	88 d8                	mov    %bl,%al
    7d52:	ee                   	out    %al,(%dx)
    7d53:	89 d8                	mov    %ebx,%eax
    7d55:	b2 f4                	mov    $0xf4,%dl
    7d57:	c1 e8 08             	shr    $0x8,%eax
    7d5a:	ee                   	out    %al,(%dx)
    7d5b:	89 d8                	mov    %ebx,%eax
    7d5d:	b2 f5                	mov    $0xf5,%dl
    7d5f:	c1 e8 10             	shr    $0x10,%eax
    7d62:	ee                   	out    %al,(%dx)
    7d63:	89 d8                	mov    %ebx,%eax
    7d65:	b2 f6                	mov    $0xf6,%dl
    7d67:	c1 e8 18             	shr    $0x18,%eax
    7d6a:	83 e0 0f             	and    $0xf,%eax
    7d6d:	83 c8 e0             	or     $0xffffffe0,%eax
    7d70:	ee                   	out    %al,(%dx)
    7d71:	b0 20                	mov    $0x20,%al
    7d73:	89 f2                	mov    %esi,%edx
    7d75:	ee                   	out    %al,(%dx)
static inline void outw(uint16_t port, uint16_t data) __attribute__((always_inline));

static inline uint8_t
inb(uint16_t port) {
	uint8_t data;
	asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
    7d76:	89 f2                	mov    %esi,%edx
    7d78:	ec                   	in     (%dx),%al
    7d79:	25 c0 00 00 00       	and    $0xc0,%eax
    7d7e:	83 f8 40             	cmp    $0x40,%eax
    7d81:	75 f3                	jne    7d76 <bootmain+0x57>
	return data;
}

static inline void
insl(uint32_t port, void *addr, int cnt) {
	asm volatile (
    7d83:	8b 7d f0             	mov    -0x10(%ebp),%edi
    7d86:	b9 80 00 00 00       	mov    $0x80,%ecx
    7d8b:	ba f0 01 00 00       	mov    $0x1f0,%edx
    7d90:	fc                   	cld    
    7d91:	f2 6d                	repnz insl (%dx),%es:(%edi)
	uint32_t secno = (offset / SECTSIZE) + 1;

	// If this is too slow, we could read lots of sectors at a time.
	// We'd write more to memory than asked, but it doesn't matter --
	// we load in increasing order.
	for (; va < end_va; va += SECTSIZE, secno ++) {
    7d93:	81 45 f0 00 02 00 00 	addl   $0x200,-0x10(%ebp)
    7d9a:	81 7d f0 00 10 01 00 	cmpl   $0x11000,-0x10(%ebp)
    7da1:	74 03                	je     7da6 <bootmain+0x87>
    7da3:	43                   	inc    %ebx
    7da4:	eb 93                	jmp    7d39 <bootmain+0x1a>
bootmain(void) {
	// read the 1st page off disk
	readseg((uintptr_t)ELFHDR, SECTSIZE * 8, 0);

	// is this a valid ELF?
	if (ELFHDR->e_magic != ELF_MAGIC) {
    7da6:	81 3d 00 00 01 00 7f 	cmpl   $0x464c457f,0x10000
    7dad:	45 4c 46 
    7db0:	75 0c                	jne    7dbe <bootmain+0x9f>
		goto bad;
	}

	cons_putc('B');
    7db2:	b8 42 00 00 00       	mov    $0x42,%eax
    7db7:	e8 b8 fe ff ff       	call   7c74 <cons_putc>
    7dbc:	eb fe                	jmp    7dbc <bootmain+0x9d>

	/* do nothing */
	while (1);

bad:
	cons_putc('E');
    7dbe:	b8 45 00 00 00       	mov    $0x45,%eax
    7dc3:	e8 ac fe ff ff       	call   7c74 <cons_putc>
	asm volatile ("outb %0, %1" :: "a" (data), "d" (port));
}

static inline void
outw(uint16_t port, uint16_t data) {
	asm volatile ("outw %0, %1" :: "a" (data), "d" (port));
    7dc8:	ba 00 8a ff ff       	mov    $0xffff8a00,%edx
    7dcd:	89 d0                	mov    %edx,%eax
    7dcf:	66 ef                	out    %ax,(%dx)
    7dd1:	b8 00 8e ff ff       	mov    $0xffff8e00,%eax
    7dd6:	66 ef                	out    %ax,(%dx)
    7dd8:	eb fe                	jmp    7dd8 <bootmain+0xb9>
